<?php
include_once('session_clientes.php');
require_once('php/class/pedidos.class.php');
$oPedido = new pedido();
$las_pedidos = @$oPedido->buscar_mio($_SESSION['id_cliente']);

if ($las_pedidos == 0) {
  $tabla = "No hay nada que ver...";
} else {
  $tabla = "<table cellpadding='0' cellspacing='0' border='0' id='table' class='tinytable'>";
  $tabla .= "<thead><tr>
	<th><h3>Fecha pedido</h3></th>
	<th><h3>Monto Total</h3></th>
	<th><h3>Estado</h3></th>
	<th class='nosort'><h3>Ver detalles</h3></th>
	</tr></thead><tbody>";

  for ($i = 0; $i < count($las_pedidos['ID']); $i++) {

    //fecha
    $fecha = $las_pedidos['FECHA_PEDIDO'][$i];
    $dia = substr($fecha, 8, 2);
    $mes = substr($fecha, 5, 2);
    $ano = substr($fecha, 0, 4);
    $fecha_cal = $dia . "-" . $mes . "-" . $ano;

    $tabla .= "<tr><td>" . $fecha_cal . "</td>";
    $tabla .= "<td>$ " . $las_pedidos['COSTO_TOTAL'][$i] . "</td>";
    if ($las_pedidos['ID_STATUS'][$i] == 4) {
      $estado = "Cerrado";
    } else {
      $estado = "En proceso";
    }
    $tabla .= "<td>" . $estado . "</td>";
    $tabla .= "<td align='center'><a href='ver_detalle_compra.php?i=" . $las_pedidos['ID'][$i] . "' rel='boxed'><img border='0' src='images/menu/ver.png'></a></td></tr>";
  }
  $tabla .= "</tbody></table>";
}
?>
<html>
  <?php include('include.header.html'); ?>
  <body class="bodycliente">
    <form id="frm_bp" name="frm_bp" method="post">

      <input type="hidden" id="id" name="id" value="<?php echo $id_cliente; ?>">

      <div id="usuario" align="center">

        <table class="marco">
          <tr>
            <td height="10%">
              <?php include('menu_clientes.php'); ?>
            </td>
          </tr>
          <tr>
            <td align="left" valign="top">
              <table width="80%" border="0">
                <tr>
                  <td rowspan="2" width="110">&nbsp;</td>
                  <td valign="top" width="100"> 
                    <table border="0" class="boton" width="100%">
                      <tr>
                        <td><a href='modificar_datos_clientes.php'>Mis Datos</a></td>
                      </tr>
                    </table>
                  </td>
                  <td valign="top" width="100"> 
                    <table border="0" class="boton" width="100%">
                      <tr>
                        <td><a href='cambio_clave_cliente.php'>Cambiar clave</a></td>
                      </tr>
                    </table>
                  </td>
                  <td valign="top" width="100"> 
                    <table border="0" class="boton" width="100%">
                      <tr>
                        <td><a href='carrito_clientes.php'>Mi Carrito</a></td>
                      </tr>
                    </table>
                  </td>
                  <td valign="top" width="100"> 
                    <table border="0" class="boton" width="100%">
                      <tr>
                        <td><a href='mis_compras_clientes'><u>Mis Compras</u></a></td>
                      </tr>
                    </table>
                  </td>
                  <td>&nbsp;</td>
                  </td>
                </tr>
                <tr>
                  <td colspan="5"> 
                    <div id="DATO_HIDE" style="display:none" style="width:90%">
                      <div id="DATO" class="mensajes">&nbsp;</div>
                    </div>
                    <div id="tablewrapper">
                      <div id="tableheader">
                        <div class="search">
                          <select id="columns" onchange="sorter.search('query')"></select>
                          <input type="text" id="query" onkeyup="sorter.search('query')" />
                        </div>
                        <span class="details">
                          <div>Registros <span id="startrecord"></span>-<span id="endrecord"></span> de <span id="totalrecords"></span></div>
                          <div><a href="javascript:sorter.reset()">reset</a></div>
                        </span>
                      </div>
                      <?php echo $tabla; ?>
                      <div id="tablefooter">
                        <div id="tablenav">
                          <div>
                            <img src="css/images/first.png" width="16" height="16" alt="First Page" onclick="sorter.move(-1,true)" />
                            <img src="css/images/previous.png" width="16" height="16" alt="First Page" onclick="sorter.move(-1)" />
                            <img src="css/images/next.png" width="16" height="16" alt="First Page" onclick="sorter.move(1)" />
                            <img src="css/images/last.png" width="16" height="16" alt="Last Page" onclick="sorter.move(1,true)" />
                          </div>
                          <div>
                            <select id="pagedropdown"></select>
                          </div>
                          <div>
                            <a href="javascript:sorter.showall()">view all</a>
                          </div>
                        </div>
                        <div id="tablelocation">
                          <div>
                            <select onchange="sorter.size(this.value)">
                              <option value="5" selected="selected">05</option>
                              <option value="10">10</option>
                              <option value="20">20</option>
                              <option value="50">50</option>
                              <option value="100">100</option>
                            </select>
                            <span>Reg. por p&aacute;g.</span>
                          </div>
                          <div class="page">P&aacute;g. <span id="currentpage"></span> de <span id="totalpages"></span></div>
                        </div>
                      </div>
                    </div>
                  </td>
                </tr>
              </table>           
            </td>
          </tr>
          <tr>
            <td height="10%" valign="bottom" align="center">
              <?php include('footer.php'); ?>
            </td>
          </tr>
        </table>

      </div>
    </form>
  </body>
  <?php include('include.footer.html'); ?>
  <script>
    /****************** POP UP *****************/
    window.addEvent('domready', function() {
 
      SqueezeBox.initialize({
        size: {x: 700, y: 350}
      });
	
      SqueezeBox.assign($$('a[rel=boxed]'), {
        
        
		
        ajaxOptions: {
          method: 'get',

        }
      });
 
    });   
    ///////////////////////////////
    var sorter = new TINY.table.sorter('sorter','table',{
      headclass:'head', // Header Class //
      ascclass:'asc', // Ascending Class //
      descclass:'desc', // Descending Class //
      evenclass:'evenrow', // Even Row Class //
      oddclass:'oddrow', // Odd Row Class //
      evenselclass:'evenselected', // Even Selected Column Class //
      oddselclass:'oddselected', // Odd Selected Column Class //
      paginate:true, // Paginate? (true or false) //
      size:5, // Initial Page Size //
      colddid:'columns', // Columns Dropdown ID (optional) //
      currentid:'currentpage', // Current Page ID (optional) //
      totalid:'totalpages', // Current Page ID (optional) //
      startingrecid:'startrecord', // Starting Record ID (optional) //
      endingrecid:'endrecord', // Ending Record ID (optional) //
      totalrecid:'totalrecords', // Total Records ID (optional) //
      hoverid:'selectedrow', // Hover Row ID (optional) //
      pageddid:'pagedropdown', // Page Dropdown ID (optional) //
      navid:'tablenav', // Table Navigation ID (optional) //
      init:true // Init Now? (true or false) //
    });
    ///////////////////////////////
  </script>
</html>
